@extends('admin.base')
@section('title', '添加商品')
@section('content')
<div class="layui-card">
    <fieldset class="layui-elem-field">
        <div class="layui-field-box">
            <a class="layui-btn-sm" href="{{url('admin/home')}}">首页</a>&raquo;
            <span class="layui-btn-sm">添加用户</span>
        </div>
    </fieldset>

    <div class="layui-card-body">
        <form class="layui-form layui-form-pane" method="post" action="{{url('/admin/user/create')}}">
            @csrf
            <div class="layui-form-item">
        <label class="layui-form-label">账号类型</label>
        <div class="layui-input-block">
            <input type="radio" name="login_type" value="1" title="手机号" checked="">
            <input type="radio" name="login_type" value="2" title="邮箱">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">账号:</label>
        <div class="layui-input-block">
            <input type="text" name="username" required lay-verify="required" placeholder="请输入账号" autocomplete="off"
                value="{{old('username')}}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">昵称:</label>
        <div class="layui-input-block">
            <input type="text" name="user" required lay-verify="required" placeholder="请输入昵称" autocomplete="off"
                value="{{old('user')}}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" id="is_invite">
        <label class="layui-form-label">邀请码:</label>
        <div class="layui-input-block">
            <input type="text" name="invite_code" placeholder="请输入邀请码" autocomplete="off"
                   value="{{old('invite_code')}}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:90px">登陆密码:</label>
        <div class="layui-input-block">
            <input type="password" name="password" required lay-verify="required" placeholder="请输入登陆密码" autocomplete="off"
                value="{{old('password')}}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:90px">二级密码:</label>
        <div class="layui-input-block">
            <input type="password" name="paypass" required lay-verify="required" placeholder="请输入二级密码" autocomplete="off"
                value="{{old('paypass')}}" class="layui-input">
        </div> 
    </div>

            <div class="layui-form-item">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </form>
    </div>
</div>
@endsection
@section('js')
<script type="text/javascript">
    layui.use(['layedit','form'],
        function() {
            var layedit = layui.layedit;
            layedit.set({
                uploadImage: {
                    url: '/admin/shop_editor',
                    type: 'post'
                }
            });
            var index = layedit.build('demo'); //建立编辑器
            var form = layui.form;
            var layedit = layui.layedit;

            //监听提交
            form.on('submit(formDemo)', function(data){
                var aa = layedit.getContent(index);
                data.field.contents = aa;
                layer.confirm('确认执行此操作？', {icon: 3, title:'提示'}, function(index){
                    ajax("{{url('admin/user/create')}}",data.field,function(data){
                        layer.close();
                        layer.closeAll();
                        layer.msg(data.msg);
                        if(data.code == 1){
                            location.href = '/admin/user/create';
                        }
                    });
                });
                return false;
            });
        });


</script>
@endsection

